package gov.ccswj.modules.job.timetask;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import gov.ccswj.common.utils.R;
import gov.ccswj.modules.bdbusiness.entity.TPageParamEntity;
import gov.ccswj.modules.bdbusiness.service.TPageParamService;
import gov.ccswj.modules.ccbusiness.service.CCompanyNameService;




/**
 * 
 * 
 * @author ZhangYx
 * @email ********@gmail.com
 * @date 2017-10-31 11:46:26
 */
@Component("TPageParamsTask")
public class TPageParamsTask {
	
    @Autowired
    private TPageParamService tPageParamService;
    @Autowired
    private CCompanyNameService ccpanynameService;
    
	public R runner(){
		int total=ccpanynameService.queryTotal();
		TPageParamEntity tp= tPageParamService.quary(1);
		tp.setTotalnum(total);
		
		int maxnum =total/tp.getLimitnum();
		if(total% tp.getLimitnum() >0){
			maxnum=maxnum+1;
		}
		
		tp.setMax_pagenum(maxnum - 1);
		
		if(tp.getPagenum() == maxnum){
			tp.setPagenum(0);
		}else{
			tp.setPagenum(tp.getPagenum()+1);
		}
		
		tPageParamService.update(tp);
	   return R.ok();
	}
	
}
